# -*- mode: snippet -*-
# name: dt.review.levels
# key: dt.review.levels
# key: dt.levels
# contributor: Shuguang Sun
# --
${1:names} <- ${2:data} |> distinct(${3:key1}, ${4:key2})
for (i in 1:nrow($1)) {
  print(c($1[i,]$$3, $1[i,]$$4))
  tn <- $1[i,]$$3
  tc <- $1[i,]$$4
  cat("Non-missing Standard Results:\n")
  print(dim($2 |> filter($3 == tn, $4 == tc)  |> count(${5:id}) ))
  cat("Non-Standard Results:\n")
  print(knitr::kable($2 |>
                 filter($3 == tn, ((is.na($4) & is.na(tc)) | $4 == tc))  |>
                 group_by($3, $4, ...)  |>
                 count($3)))
}
